<include file="public@header" />
<style>
    html {background-color: #ffffff;}
    #container {width:100%; height: 300px; }
</style>

</head>
<body>
<div class="layui-fluid">
    <form method="post" class="layui-form js-ajax-form" style="margin-top:20px ;" action="{:url('merchant.store/editPost')}">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-tab layui-tab-brief">
                    <ul class="layui-tab-title">
                        <li ><a href="javascript:history.go(-1)">列表</a></li>
                        <li class="layui-this"><a >{:lang('EDIT')}</a></li>
                    </ul>
                </div>

                <div class="layui-card-body">
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="form-required">*</span>店铺类型</label>
                        <div class="layui-input-block">
                            <select class="layui-input" name="type_id" id="type_id" lay-filter="type_id">
                                <volist name="typelist" id="v">
                                    <option value="{$v['id']}" <eq name="$data.type_id" value="$v['id']">selected</eq>>{$v['html']}{$v['name']}</option>
                                </volist>
                            </select>
                            <p>如需修改店铺顶级类型,需要先删除店铺下的所有商品</p>
                        </div>
                    </div>
    

                    <if condition="in_array($top_type_id,[1,3,4,5,6,7,8])">
                    <div class="layui-form-item">
                        <input type="hidden" name="recommend" value="0">
                    </div>
                    </if>
                    <if condition="in_array($top_type_id,[4])">
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="form-required">*</span>吃喝玩乐(找店)</label>
                        <div class="layui-input-block">
                            <select class="layui-input" name="beer_and_skittles" id="beer_and_skittles" lay-filter="beer_and_skittles">
                                <option value="0">否</option>
                                <option value="1" <eq name="$data.beer_and_skittles" value="1">selected</eq>>是</option>
                            </select>
                        </div>
                    </div>
                    </if>

                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="form-required">*</span>店铺名称</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" name="name" value="{$data.name}" required>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="form-required">*</span>店铺封面</label>
                        <div class="layui-input-block">
                            <input type="hidden" name="thumb" id="thumb" value="{$data.thumb}">
                            <a href="javascript:uploadOneImage('图片上传','#thumb');">
                                <if condition="$data.thumb ?? ''">
                                    <img src="{$data.thumb}" id="thumb-preview" style="cursor: pointer;max-width:150px;max-height:150px;"/>
                                    <else/>
                                    <img src="__TMPL__/public/assets/images/default-thumbnail.png" id="thumb-preview" style="cursor: pointer;max-width:150px;max-height:150px;"/>
                                </if>
                            </a>
                            <div class="layui-col-md12" style="margin-top: 10px">
                                <input type="button" class="layui-btn layui-btn-sm layui-btn-normal"
                                       onclick="$('#thumb-preview').attr('src','__TMPL__/public/assets/images/default-thumbnail.png');$('#thumb').val('');return false;"
                                       value="取消图片">
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item" style="display: none;">
                        <label class="layui-form-label"><span class="form-required">*</span>店铺背景</label>
                        <div class="layui-input-block">
                            <input type="hidden" name="background" id="background" value="{$data.background}">
                            <a href="javascript:uploadOneImage('图片上传','#background');">
                                <if condition="$data.background ?? ''">
                                    <img src="{$data.background}" id="background-preview" style="cursor: pointer;max-width:150px;max-height:150px;"/>
                                    <else/>
                                    <img src="__TMPL__/public/assets/images/default-thumbnail.png" id="background-preview" style="cursor: pointer;max-width:150px;max-height:150px;"/>
                                </if>
                            </a>
                            <div class="layui-col-md12" style="margin-top: 10px">
                                <input type="button" class="layui-btn layui-btn-sm layui-btn-normal"
                                       onclick="$('#background-preview').attr('src','__TMPL__/public/assets/images/default-thumbnail.png');$('#background').val('');return false;"
                                       value="取消图片">
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="form-required">*</span>店铺地址</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" name="address" id="address" value="{$data.address}" required>
                            <input type="hidden" class="layui-input" name="lng" id="lng" value="{$data.lng}" required>
                            <input type="hidden" class="layui-input" name="lat" id="lat" value="{$data.lat}" required>
                            <div id="container"></div>

                        </div>
                    </div>

                    <if condition="in_array($top_type_id,[1,3,5,6,7,8])">

                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="form-required">*</span>店铺环境</label>
                        <div class="layui-input-inline">
                            <input type="hidden" name="environment_0" id="environment_0"  value="{$data.environment.0  ?? ''}">
                            <a href="javascript:uploadOneImage('图片上传','#environment_0');">
                                <if condition="$data.environment.0 ?? ''">
                                    <img src="{$data.environment.0}" id="environment_0-preview" style="cursor: pointer;max-width:150px;max-height:150px;"/>
                                    <else/>
                                    <img src="__TMPL__/public/assets/images/default-thumbnail.png" id="environment_0-preview" style="cursor: pointer;max-width:150px;max-height:150px;"/>
                                </if>
                            </a>
                            <div class="layui-col-md12" style="margin-top: 10px">
                                <input type="button" class="layui-btn layui-btn-sm layui-btn-normal"
                                       onclick="$('#environment_0-preview').attr('src','__TMPL__/public/assets/images/default-thumbnail.png');$('#environment_0').val('');return false;"
                                       value="取消图片">
                            </div>
                        </div>
                        <div class="layui-input-inline">
                            <input type="hidden" name="environment_1" id="environment_1"  value="{$data.environment.1  ?? ''}">
                            <a href="javascript:uploadOneImage('图片上传','#environment_1');">
                                <if condition="$data.environment.1 ?? ''">
                                    <img src="{$data.environment.1}" id="environment_1-preview" style="cursor: pointer;max-width:150px;max-height:150px;"/>
                                    <else/>
                                    <img src="__TMPL__/public/assets/images/default-thumbnail.png" id="environment_1-preview" style="cursor: pointer;max-width:150px;max-height:150px;"/>
                                </if>
                            </a>
                            <div class="layui-col-md12" style="margin-top: 10px">
                                <input type="button" class="layui-btn layui-btn-sm layui-btn-normal"
                                       onclick="$('#environment_1-preview').attr('src','__TMPL__/public/assets/images/default-thumbnail.png');$('#environment_1').val('');return false;"
                                       value="取消图片">
                            </div>
                        </div>
                        <div class="layui-input-inline">
                            <input type="hidden" name="environment_2" id="environment_2"  value="{$data.environment.2 ?? ''}">
                            <a href="javascript:uploadOneImage('图片上传','#environment_2');">
                                <if condition="$data.environment.2 ?? ''">
                                    <img src="{$data.environment.2}" id="environment_2-preview" style="cursor: pointer;max-width:150px;max-height:150px;"/>
                                    <else/>
                                    <img src="__TMPL__/public/assets/images/default-thumbnail.png" id="environment_2-preview" style="cursor: pointer;max-width:150px;max-height:150px;"/>
                                </if>
                            </a>
                            <div class="layui-col-md12" style="margin-top: 10px">
                                <input type="button" class="layui-btn layui-btn-sm layui-btn-normal"
                                       onclick="$('#environment_2-preview').attr('src','__TMPL__/public/assets/images/default-thumbnail.png');$('#environment_2').val('');return false;"
                                       value="取消图片">
                            </div>
                        </div>
                        <div class="layui-input-inline">
                            <input type="hidden" name="environment_3" id="environment_3"  value="{$data.environment.3 ?? ''}">
                            <a href="javascript:uploadOneImage('图片上传','#environment_3');">
                                <if condition="$data.environment.3 ?? ''">
                                    <img src="{$data.environment.3}" id="environment_3-preview" style="cursor: pointer;max-width:150px;max-height:150px;"/>
                                    <else/>
                                    <img src="__TMPL__/public/assets/images/default-thumbnail.png" id="environment_3-preview" style="cursor: pointer;max-width:150px;max-height:150px;"/>
                                </if>
                            </a>
                            <div class="layui-col-md12" style="margin-top: 10px">
                                <input type="button" class="layui-btn layui-btn-sm layui-btn-normal"
                                       onclick="$('#environment_3-preview').attr('src','__TMPL__/public/assets/images/default-thumbnail.png');$('#environment_3').val('');return false;"
                                       value="取消图片">
                            </div>
                        </div>
                        <div class="layui-input-inline">
                            <input type="hidden" name="environment_4" id="environment_4"  value="{$data.environment.4 ?? ''}">
                            <a href="javascript:uploadOneImage('图片上传','#environment_4');">
                                <if condition="$data.environment.4 ?? ''">
                                    <img src="{$data.environment.4}" id="environment_4-preview" style="cursor: pointer;max-width:150px;max-height:150px;"/>
                                    <else/>
                                    <img src="__TMPL__/public/assets/images/default-thumbnail.png" id="environment_4-preview" style="cursor: pointer;max-width:150px;max-height:150px;"/>
                                </if>
                            </a>
                            <div class="layui-col-md12" style="margin-top: 10px">
                                <input type="button" class="layui-btn layui-btn-sm layui-btn-normal"
                                       onclick="$('#environment_4-preview').attr('src','__TMPL__/public/assets/images/default-thumbnail.png');$('#environment_4').val('');return false;"
                                       value="取消图片">
                            </div>
                        </div>
                    </div>
                    </if>

                    <if condition="in_array($top_type_id,[1,5,6,7,8])">
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="form-required">*</span>法人姓名</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" name="person_name" required value="{$industry.name ?? ''}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="form-required">*</span>身份证号</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" name="id_card" required value="{$industry.id_card ?? ''}">
                        </div>
                    </div>


                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="form-required">*</span>身份证照片(正面)</label>
                        <div class="layui-input-block">
                            <input type="hidden" name="id_card_image_0" id="id_card_image_0" value="{$industry.id_card_image.0 ?? ''}">
                            <a href="javascript:uploadOneImage('图片上传','#id_card_image_0');">
                                <if condition="$industry.id_card_image.0 ?? ''">
                                    <img src="{$industry.id_card_image.0}" id="id_card_image_0-preview" style="cursor: pointer;max-width:150px;max-height:150px;"/>
                                    <else/>
                                    <img src="__TMPL__/public/assets/images/default-thumbnail.png" id="id_card_image_0-preview" style="cursor: pointer;max-width:150px;max-height:150px;"/>
                                </if>
                            </a>
                            <div class="layui-col-md12" style="margin-top: 10px">
                                <input type="button" class="layui-btn layui-btn-sm layui-btn-normal"
                                       onclick="$('#id_card_image_0-preview').attr('src','__TMPL__/public/assets/images/default-thumbnail.png');$('#id_card_image_0').val('');return false;"
                                       value="取消图片">
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="form-required">*</span>身份证照片(反面)</label>
                        <div class="layui-input-block">
                            <input type="hidden" name="id_card_image_1" id="id_card_image_1" value="{$industry.id_card_image.1 ?? ''}">
                            <a href="javascript:uploadOneImage('图片上传','#id_card_image_1');">
                                <if condition="$industry.id_card_image.1 ?? ''">
                                    <img src="{$industry.id_card_image.1}" id="id_card_image_1-preview" style="cursor: pointer;max-width:150px;max-height:150px;"/>
                                    <else/>
                                    <img src="__TMPL__/public/assets/images/default-thumbnail.png" id="id_card_image_1-preview" style="cursor: pointer;max-width:150px;max-height:150px;"/>
                                </if>
                            </a>
                            <div class="layui-col-md12" style="margin-top: 10px">
                                <input type="button" class="layui-btn layui-btn-sm layui-btn-normal"
                                       onclick="$('#id_card_image_1-preview').attr('src','__TMPL__/public/assets/images/default-thumbnail.png');$('#id_card_image_1').val('');return false;"
                                       value="取消图片">
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="form-required">*</span>工商注册号</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" name="registr_id" required value="{$industry.registr_id  ?? ''}">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="form-required">*</span>营业执照(正面)</label>
                        <div class="layui-input-block">
                            <input type="hidden" name="business_image_0" id="business_image_0" value="{$industry.business_image.0 ?? ''}">
                            <a href="javascript:uploadOneImage('图片上传','#business_image_0');">
                                <if condition="$industry.business_image.0 ?? ''">
                                    <img src="{$industry.business_image.0}" id="business_image_0-preview" style="cursor: pointer;max-width:150px;max-height:150px;"/>
                                    <else/>
                                    <img src="__TMPL__/public/assets/images/default-thumbnail.png" id="business_image_0-preview" style="cursor: pointer;max-width:150px;max-height:150px;"/>
                                </if>
                            </a>
                            <div class="layui-col-md12" style="margin-top: 10px">
                                <input type="button" class="layui-btn layui-btn-sm layui-btn-normal"
                                       onclick="$('#business_image_0-preview').attr('src','__TMPL__/public/assets/images/default-thumbnail.png');$('#business_image_0').val('');return false;"
                                       value="取消图片">
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="form-required">*</span>许可证编号</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" name="license_number" value="{$industry.license_number ?? ''}" required>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="form-required">*</span>许可证照</label>
                        <div class="layui-input-block">
                            <input type="hidden" name="license_image_0" id="license_image_0" value="{$industry.license_image.0 ?? ''}">
                            <a href="javascript:uploadOneImage('图片上传','#license_image_0');">
                                <if condition="$industry.license_image.0 ?? ''">
                                    <img src="{$industry.license_image.0}" id="license_image_0-preview" style="cursor: pointer;max-width:150px;max-height:150px;"/>
                                <else/>
                                    <img src="__TMPL__/public/assets/images/default-thumbnail.png" id="license_image_0-preview" style="cursor: pointer;max-width:150px;max-height:150px;"/>
                                </if>
                            </a>
                            <div class="layui-col-md12" style="margin-top: 10px">
                                <input type="button" class="layui-btn layui-btn-sm layui-btn-normal"
                                       onclick="$('#license_image_0-preview').attr('src','__TMPL__/public/assets/images/default-thumbnail.png');$('#license_image_0').val('');return false;"
                                       value="取消图片">
                            </div>
                        </div>
                    </div>
                    </if>
                    <if condition="in_array($top_type_id,[3])">
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">关于</label>
                            <div class="layui-input-block">
                                <textarea class="layui-textarea" name="about" >{$data.about}</textarea>
                            </div>
                        </div>
                    </if>
                    <input type="hidden" name="id" value="{$data.id}">

                    <if condition="in_array($top_type_id,[4])">
                    <div class="layui-form-item">
                        <label class="layui-form-label">人均消费(找店)</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" name="per_capita" value="{$data.per_capita}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">总评分(找店)</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" name="stars" value="{$data.stars}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">口味评分(找店)</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" name="taste_score" value="{$data.taste_score}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">环境评分(找店)</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" name="environment_score" value="{$data.environment_score}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">服务评分(找店)</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" name="service_score" value="{$data.service_score}">
                        </div>
                    </div>
                    </if>

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button type="submit" class="layui-btn js-ajax-submit">{:lang('EDIT')}</button>
                            <a class="layui-btn layui-btn-primary btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<include file="public@script"/>
<script type="text/javascript">
    window._AMapSecurityConfig = {
        securityJsCode:'{$gaode_secret}',
    }
</script>
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key={$gaode_key}"></script>
<script type="text/javascript">
    //地图加载
    var map = new AMap.Map("container", {
        resizeEnable: true
    });

    map.plugin(['AMap.Autocomplete','AMap.PlaceSearch'], function(){
        // 实例化Autocomplete
        var autoOptions = {
            // input 为绑定输入提示功能的input的DOM ID
            input: 'address'
        }
        var auto= new AMap.Autocomplete(autoOptions);

        // 无需再手动执行search方法，autoComplete会根据传入input对应的DOM动态触发search
        var placeSearch = new AMap.PlaceSearch({
            map: map
        });
        //构造地点查询类
        auto.on("select", select);//注册监听，当选中某条记录时会触发
        function select(e) {

            placeSearch.search(e.poi.name, function (status, result) {
                //关键字查询
                placeSearch.search(e.poi.name);
                placeSearch.on('markerClick',function(e){
                    $('#address').val(e.data.address+' '+e.data.name);
                    $('#lng').val(e.event.lnglat.lng);
                    $('#lat').val(e.event.lnglat.lat);
                })
            });
        }
    })


    var marker = new AMap.Marker({
        position: new AMap.LngLat({$lng}, {$lat}),   // 经纬度对象，也可以是经纬度构成的一维数组[116.39, 39.9]
    });

    // 将创建的点标记添加到已有的地图实例：
    map.add(marker);

</script>
</body>
</html>